﻿#region Copyrights Notice
//©2009 Microsoft Corporation.  All rights reserved.
//This portal design is based on the design and some code from DropThings.com which is also licensed under an MS-PL license.
#endregion


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Microsoft.InformationSecurity.CISF.Portal.Business.PortalFramework;
using Microsoft.InformationSecurity.CISF.Portal.Business;
using FACTORY = Microsoft.InformationSecurity.RiskManagement.ISRMWeb.Common;

namespace Microsoft.InformationSecurity.RiskManagement.ISRMWeb.UserControls
{
    public class WebletContainerBase 
    {
        public IWeblet m_ctrlWebletControl;
        public RealWeblet m_ctrlRealWebletControl;
        public bool m_bLoadFirstTime;
        
        public RealWeblet RealWebletControl
        {
            get { return m_ctrlRealWebletControl; }
            set { m_ctrlRealWebletControl = value; }
        }


        int GetControlID()
        {
            return this.RealWebletControl.WidgetInstanceId;
        }
        /* Begin - Implement IWebletContainer */
        

        void SetState(string state, string userid)
        {
            //Todo -  Update database...
            var PortalFacade = new PortalFacade(userid);

            if (!PortalFacade.UpdateWidgetState(RealWebletControl.WidgetId, state)) { } //Success
            else { }//Failure.
        }

        string GetState()
        {
            return RealWebletControl.State;
        }
        

        void ControlDisplaySettings(bool bShow)
        {
            
            this.m_ctrlWebletControl.DisplaySettings(bShow);                  

        }

        public bool FirstTime
        {
            get { return m_bLoadFirstTime; }
            set { m_bLoadFirstTime = value; }
        }
        public string GetControlRelativeUrl()
        {
            return RealWebletControl.SingleWeblet.Url;
        }

        public int GetControlID2()
        {
            return RealWebletControl.WidgetInstanceId;
        }

    }
}